using System;
using System.Collections.Generic;
using Me.Prettyprint.Cassandra.Model;
using Me.Prettyprint.Cassandra.Model.Thrift;
using Me.Prettyprint.Cassandra.Service;
using Me.Prettyprint.Hector.Api;
using Me.Prettyprint.Hector.Api.Factory;
using Me.Prettyprint.Hector.Api.Mutation;
using Thrift;

namespace Me.Prettyprint.Cassandra.Service.Template
{
    public abstract class AbstractTemplateUpdater<K, N>
	{
        protected const int DEF_TTL = 0;
        protected int KeyPos = 0;
        public AbstractTemplateUpdater(AbstractColumnFamilyTemplate<K, N> template, ColumnFactory columnFactory, Mutator<K> mutator) 
        {
            Template = template;
            ColumnFactory = columnFactory;
            CurrentMutator = mutator;
            Clock = template.Clock;
            ConsistencyLevelPolicy = template.ConsistencyLevelPolicy;
            Ttl = DEF_TTL; 
        }
        public AbstractTemplateUpdater(ColumnFactory columnFactory, Mutator<K> mutator)
        {
            ColumnFactory = columnFactory;
            CurrentMutator = mutator;
            Ttl = DEF_TTL;
        }
        protected List<K> Keys
        {
            get;
            set;
        }
        protected ColumnFactory ColumnFactory
        {
            get;
            set;
        }
        protected AbstractColumnFamilyTemplate<K, N> Template
        {
            get;
            set;
        }
        public Mutator<K> CurrentMutator
        {
            get;
            protected set;
        }
        public long Clock
        {
            get;
            set;
        }
        public int Ttl
        {
            get;
            set;
        }
        /// <summary>
        /// Set the ConsistencyLevelPolicy to tune consistency to the desired level
        /// </summary>
        public ConsistencyLevelPolicy ConsistencyLevelPolicy
        {
            get;
            set;
        }
        public AbstractTemplateUpdater<K, N> AddKey(K key)
        {
            if (Keys == null)
            {
                Keys = new List<K>();
            }
            else
            {
                KeyPos++;
            }
            Keys.Add(key);
            return this;
        }
        public K GetCurrentKey()
        {
            return Keys[KeyPos];
        }
        public void Update()
        {
        }
	}
}